package com.jhhc.StormSurgeForecast.AstronomicalTide.Pojo.DTO;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class OutFileData {

    //时间
    private String tm;
    //@JsonInclude(JsonInclude.Include.NON_NULL)
    private Double tdz;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Double twc;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String month;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Double zs;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String day;
    //根据天分组
    public String getDay() {
        return setDay();
    }

    public String getTm() {
        return tm;
    }

    public void setTm(String tm) {
        this.tm = tm;
    }

    public Double getTdz() {
        return tdz;
    }

    public void setTdz(Double tdz) {
        this.tdz = tdz;
    }

    public Double getTwc() {
        return twc;
    }

    public void setTwc(Double twc) {
        this.twc = twc;
    }

    public Double getZs() {
        return zs;
    }

    public void setZs(Double zs) {
        this.zs = zs;
    }

    public String setDay() {
        String month1 = getTm();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 日期格式转换 月份
        try {

            return  format.format(format.parse(month1)).substring(0,10);

        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
    @JSONField(serialize = false)
    public String getMonth() {
        return setMonth();
    }
    @JSONField(serialize = false)
    public String setMonth() {
        String month1 = getTm();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 日期格式转换 月份
        try {

            return  format.format(format.parse(month1)).substring(0,7);

        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public String toString() {
        return "OutFileData{" +
                "tm='" + tm + '\'' +
                ", tdz=" + tdz +
                ", twc=" + twc +
                ", zs=" + zs +
                '}';
    }
}
